#ifndef EMV_PARAM_CPP_H
#define EMV_PARAM_CPP_H



#include "DataType.h"

enum TransMode
{
    TRAN_MODE_ICC,
    TRAN_MODE_RF
};

enum TransType
{
    EMV_TRANS_GOODS,/*ªıŒÔ*/
    EMV_TRANS_SERVICES,/*∑˛ŒÒ*/
    EMV_TRANS_CASH,/*œ÷Ω*/
    EMV_TRANS_CASHBACK,/*∑µœ÷*/
    EMV_TRANS_INQUIRY,/*≤È—Ø*/
    EMV_TRANS_TRANFER,/*◊™’À*/
    EMV_TRANS_ADMIN,/*π‹¿Ì*/
    EMV_TRANS_CASHDEPOSIT,/*¥ÊøÓ*/
    EMV_TRANS_PAYMENT,/*÷ß∏∂*/
    EMV_TRANS_PBOCLOG,
    EMV_TRANS_PREAUTH ,

    /*  ----------------        Ω”¥•µÁ◊”œ÷ΩΩª“◊¿‡–Õ    ----------------    */
    EMV_TRANS_EC_GOODS ,/*µÁ◊”œ÷ΩªıŒÔ*/
    EMV_TRANS_EC_SERVICES ,/*µÁ◊”œ÷Ω∑˛ŒÒ*/
    EMV_TRANS_EC_BINDLOAD ,/*µÁ◊”œ÷Ω÷∏∂®’Àªß»¶¥Ê*/
    EMV_TRANS_EC_NOBINDLOAD ,/*µÁ◊”œ÷Ω∑«÷∏∂®’Àªß»¶¥Ê*/
    EMV_TRANS_EC_CASHLOAD ,/*µÁ◊”œ÷Ωœ÷Ω»¶¥Ê*/
    EMV_TRANS_EC_UPLOAD ,/*µÁ◊”œ÷Ω»¶Ã·(‘›Œ¥ µœ÷)*/
    EMV_TRANS_EC_INQUIRE_LOG ,/*µÁ◊”œ÷Ω»’÷æ(∫ÕPBOC»’÷æ“ª—˘)*/
    EMV_TRANS_EC_INQUIRE_AMOUNT ,
    EMV_TRANS_EC_CASHLOAD_VOID ,/*µÁ◊”œ÷Ωœ÷Ω»¶¥Ê≥∑œ˙*/
    EMV_TRANS_EC_LOADLOG ,/*»¶¥Ê»’÷æ*/

    /*  ----------------        ∑«Ω”¥•µÁ◊”œ÷ΩQPBOCΩª“◊¿‡–Õ    ----------------    */
    EMV_TRANS_RF_GOODS ,/*QPBOC/MSDªıŒÔ*/
    EMV_TRANS_RF_SERVICES ,/*QPBOC/MSD∑˛ŒÒ*/
    EMV_TRANS_RF_START ,/*÷ª◊ˆ±Í ∂≤ª◊ˆΩª“◊¿‡–Õ*/
    EMV_TRANS_RF_BINDLOAD ,/*∑«Ω”÷∏∂®’Àªß»¶¥Ê*/
    EMV_TRANS_RF_NOBINDLOAD ,/*∑«Ω”œ÷Ω∑«÷∏∂®’Àªß»¶¥Ê*/
    EMV_TRANS_RF_CASHLOAD ,/*∑«Ω”œ÷Ωœ÷Ω»¶¥Ê*/
    EMV_TRANS_RF_INQUIRE_AMOUNT ,/* QPBOC”‡∂Ó≤È—Ø
    °°                                                               (µ±emv_rf_start( )∫Ø ˝∑µªÿŒ™:
    °°                                                               TRANS_RF_GOON_AMOUNT, ≤≈±Ì æªÒ
    °°                                                               »°”‡∂Ó≥…π¶(≤¢ø…“‘Õ®π˝EMV_getdataªÒ»°
                                                                    9F77µÁ◊”œ÷Ω”‡∂Ó…œœﬁ)£¨∑Ò‘Ú ß∞‹)*/
    EMV_TRANS_RF_UPLOAD ,/*∑«Ω”œ÷Ω»¶Ã·(‘›Œ¥ µœ÷)*/
    EMV_TRANS_RF_CASHLOAD_VOID ,/*∑«Ω”œ÷Ωœ÷Ω»¶¥Ê≥∑œ˙*/
    EMV_TRANS_RF_PBOCLOG ,/*∑«Ω”»°PBOC√˜œ∏*/
    EMV_TRANS_RF_UPTCARDINFO ,/*ø®∆¨–≈œ¢–¥»Î*/
    EMV_TRANS_RF_LOADLOG
};



enum TransEmvSeq
{
    EMV_PROC_TO_APPSEL_INIT,        /*”¶”√—°‘Ò≥ı ºªØ*/
    EMV_PROC_TO_READAPPDATA,        /*∂¡”¶”√ ˝æ›*/
    EMV_PROC_TO_OFFLINEAUTH,        /*¿Îœﬂ ˝æ›»œ÷§*/
    EMV_PROC_TO_RESTRITCT,          /*¥¶¿Ìœﬁ÷∆*/
    EMV_PROC_TO_CV,                 /*≥÷ø®»À—È÷§*/
    EMV_PROC_TO_RISKMANA,           /*÷’∂À∑Áœ’π‹¿Ì*/
    EMV_PROC_TO_1GENAC,             /*µ⁄“ª¥Œ√‹Œƒ…˙≥…*/
    EMV_PROC_TO_2GENAC,             /*µ⁄∂˛¥Œ√‹Œƒ…˙≥…*/
    EMV_PROC_CONTINUE               /*Ωª“◊ÕÍ≥…*/
};

enum TransReqAmt
{
    EMV_TRANS_REQAMT_NO,/*≤ª ‰»ÎΩ∂Ó*/
    EMV_TRANS_REQAMT_APS,/*”¶”√—°‘Ò ± ‰»Î*/
    EMV_TRANS_REQAMT_DDA,/* ˝æ›»œ÷§ ± ‰»Î*/
    EMV_TRANS_REQAMT_RFPRECESS,/*∑«Ω”¥•Ωª“◊‘§¥¶¿Ì ± ‰»Î*/
    EMV_TRANS_REQAMT_BFTRANS/*Ωª“◊«∞ ‰»ÎΩ∂Ó*/
};

enum TransOnlineResult
{
    EMV_TRANS_ONLINEFAIL,/*¡™ª˙ ß∞‹*/
    EMV_TRANS_ONLINESUCC_ACCEPT ,/*¡™ª˙≥…π¶≤¢ ⁄ ‹Ωª“◊*/
    EMV_TRANS_ONLINESUCC_DENIAL,/*¡™ª˙≥…π¶≤¢æ‹æ¯≤Œøº*/
    EMV_TRANS_ONLINESUCC_ISSREF,/*¡™ª˙≥…π¶≤¢∑µªÿ≤Œøº*/
};

enum RfTransId
{
    KEEP_ORIGINAL,
    ONLY_PBOC,
    ONLY_QPBOC
};

//class ArqSimpleTransceiver;

class EmvParam
{
private:
    static string TAG;
    
private:
    bool D = true;
    TransMode mTransMode = TRAN_MODE_ICC;
    TransType mTransType = EMV_TRANS_GOODS;
    TransEmvSeq mTransEmvSeq = EMV_PROC_CONTINUE;
    TransReqAmt mTransReqAmt = EMV_TRANS_REQAMT_NO;
    RfTransId mRfTransId = KEEP_ORIGINAL;
    bool mForceOnline = false;
    bool mAccounSel = false;
    double mCash = 0.00;
    double mCashBack = 0.00;
    byte  mTime[7];
    byte mAuthRespCode[2];
    TransOnlineResult mTransOnlineResult = EMV_TRANS_ONLINEFAIL;
    int mRecvField55Len = 0;
    byte mRecvField55[512];
    
    int pinAlgorithm = 0;
    int pinParamLen = 0;
    byte* pinParam = NULL;

    int mExtendParamLen = 0;
    byte* mExtendParam = NULL;
    
public:
    int setTransMode(TransMode transMode);
    TransMode getTransMode();
    int setTransType(TransType transType);
    TransType getTransType();
    int setTransEmvSeq(TransEmvSeq transEmvSeq);
    TransEmvSeq getTransEmvSeq();
    int setTransReqAmt(TransReqAmt transReqAmt);
    TransReqAmt getTransReqAmt();
    int setRfTransId(RfTransId id);
    RfTransId getRfTransId();
    void setForceOnline(bool enable);
    bool isForceOnline();
    void setAccounSel(bool enable);
    bool isAccounSel();
    void setCash(double cash);
    double getCash();
    void setCashBack(double cash);
    double getCashBack();
    int setTime(string date);
    string getTime();
    int setAuthRespCode(byte *code, int offset);
    byte *getAuthRespCode();
    int setTransOnlineResult(TransOnlineResult transOnlineResult);
    TransOnlineResult getTransOnlineResult();
    int setRecvField55(byte* data, int offset, int len);
    int getRecvField55(byte *data);
    void setPinAlgorithm(int algorithm);
    void setPinParam(byte* param, int param_len);
    void setExtendParam(byte* param, int param_len);
    
    byte getTransModeVal();
    byte getTransTypeVal();
    byte getTransEmvSeqVal();
    byte getTransReqAmtVal() ;
    byte getTransOnlineResultVal();
    byte getEnableVal(bool enable);
    int outEmvParam(byte* out, int pos);
};


#endif
